home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6098 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  971 b 

  1. Path: ix.netcom.com!netnews
  2. From: swampwiz@ix.netcom.com(Jean P. Laborde )
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How to delete array of pointers?
  5. Date: 10 Feb 1996 14:07:41 GMT
  6. Organization: Netcom
  7. Message-ID: <4fi8rd$738@reader2.ix.netcom.com>
  8. References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk>
  9. NNTP-Posting-Host: ix-no1-15.ix.netcom.com
  10. X-NETCOM-Date: Sat Feb 10  6:07:41 AM PST 1996
  11.  
  12. In <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> ywleung@cs.cuhk.hk (Marty McFly)
  13. writes: 
  14. >
  15. >If I write the following code in a function:
  16. >
  17. >    int** ptr;
  18. >    ptr = new int*[1000];
  19. >
  20. >Is this code means allocating 1000 integer pointers which is pointed
  21. by ptr?
  22. >And then somehow I assign integer variable to ptr[0], ptr[1], ... and
  23. so on.
  24. >So at the end of the function, how can I reclaim just those pointers? 
  25. The key
  26. >point is that those integer variable assigned to the pointers should
  27. not be 
  28. >deleted.
  29. >
  30. >Regards,
  31. >Marty McFly.
  32.  
  33. how about:
  34.  
  35. for(int i=0;i<1000;i++)
  36.     delete ptr[i];
  37. delete ptr;
  38.  
  39.  
  40.